use std::ops;

fn main() {
    println!("Foo+Bar={:?}", Foo + Bar);
    println!("Bar+Foo={:?}", Bar + Foo);
}

struct Foo;
struct Bar;
#[derive(Debug)]
struct FooBar;
#[derive(Debug)]
struct BarFoo;

impl ops::Add<Bar> for Foo {
    // 这里要指定输出的类型哦，就是相加后输出的类型
    type Output = FooBar;

    fn add(self, _rhs: Bar) -> FooBar {
        println!("> Foo.add(Bar) was called");
        FooBar
    }
}

impl ops::Add<Foo> for Bar {
    type Output = BarFoo;

    fn add(self, _rhs: Foo) -> BarFoo {
        println!("> Bar.add(Foo) was called");
        BarFoo
    }
}
